package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
/**
 * 日报
 */
public class Daily extends BaseDomain {
    public static final int COMMON_NOMSL=0;//普通
    public static final int HEADLINE_HOT=1;//推荐
    //日报标题
    private String title;
    //日报创建时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd" ,timezone = "GMT+8")
    private Date dailyCreateTime;
    //日报状态
    private Integer state;
    //点赞数量
    private Integer likes;
    //日报内容
    private DailyContent content;
    //日报评论内容
    private DailyReview dailyReview;
    //最后更新时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd" ,timezone = "GMT+8")
    private Date lastUpdateTime;
    //日报封面
    private String coverUrl;
    public String getJson(){
        Map<String,Object> map=new HashMap<>();
        map.put("state", state);
        map.put("title", title);
        map.put("coverUrl", coverUrl);
        map.put("id", getId());
        return JSONUtil.toJSONString(map);
    }
}